package com.bupt.liutong.admin.bbs.dao;

import java.util.List;

import com.bupt.liutong.admin.core.base.Ibatis;
import com.bupt.liutong.admin.bbs.dto.Post;

public class PostDao {

	protected Ibatis ibatis;

	@SuppressWarnings("unchecked")
	public List<Post> getPostsByPage(Post post) {
		return (List<Post>) ibatis.queryForPage("bbs_post.getPosts", post);
	}

	@SuppressWarnings("unchecked")
	public List<Post> getRepliesByPage(Post post) {
		return (List<Post>) ibatis.queryForPage("bbs_post.getReplies", post);
	}

	public Post getPostById(Long id) {
		return (Post) ibatis.queryForObject("bbs_post.getPostById", id);
	}

	public Integer insertPost(Post post) {
		return (Integer) ibatis.insert("bbs_post.insertPost", post);
	}

	public void updatePost(Post post) {
		ibatis.update("bbs_post.updatePost", post);
	}

	public void deletePost(Long id) {
		ibatis.delete("bbs_post.deletePost", id);
	}

	public void setIbatis(Ibatis ibatis) {
		this.ibatis = ibatis;
	}
}
